﻿using DataModels.Dto;
using DataModels.Dto.Home;
using Microsoft.AspNetCore.Mvc;
using Services.Home;
using Utils;

namespace PropertyManagementWebApi.Controllers.Home
{
    public class HomeServiceController(HomeService homeService) : BaseController
    {
        protected readonly HomeService _homeService = homeService;

        /// <summary>
        /// 获取所有商品分类
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        public ResponseModel GetProductCategory()
        {
            return _homeService.GetProductCategory();
        }

        /// <summary>
        /// 商品主查询
        /// </summary>
        /// <param name="info"></param>
        /// <returns></returns>
        [HttpGet]
        public ResponseModel GetProduct([FromQuery] GetProductInfo info)
        {
            return _homeService.GetProduct(info);
        }

        /// <summary>
        /// 商品详情查询
        /// </summary>
        /// <param name="uuid"></param>
        /// <returns></returns>
        [HttpGet]
        public ResponseModel GetProductDetail([GeneralRequired] Guid uuid)
        {
            return _homeService.GetProductDetail(uuid);
        }

        /// <summary>
        /// 提交订单
        /// </summary>
        /// <param name="info"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<ResponseModel> SubmitOrderAsync(SubmitOrderInfo info)
        {
            return await _homeService.SubmitOrder(info);
        }

        /// <summary>
        /// 付款
        /// </summary>
        /// <param name="info"></param>
        /// <returns></returns>
        [HttpPost]
        public ResponseModel OrderPayment(OrderPaymentInfo info)
        {
            return _homeService.OrderPayment(info.OrderUUID,DataModels.Enums.GeneralEnum.PayWay.VX);
        }

        /// <summary>
        /// 获取评论综合信息
        /// </summary>
        /// <param name="productUUID"></param>
        /// <returns></returns>
        [HttpGet]
        public ResponseModel GetCommentStatistics([GeneralRequired] Guid productUUID)
        {
            return _homeService.GetCommentStatistics(productUUID);
        }

        /// <summary>
        /// 获取评论详情
        /// </summary>
        /// <param name="info"></param>
        /// <returns></returns>
        [HttpGet]
        public ResponseModel GetOrderComment([FromQuery] GetOrderCommentInfo info)
        {
            return _homeService.GetOrderComment(info);
        }

        /// <summary>
        /// 评论完成的订单
        /// </summary>
        /// <param name="info"></param>
        /// <returns></returns>
        [HttpPost]
        public ResponseModel SubmitOrderComment([FromBody] SubmitOrderComment info)
        {
            return _homeService.SubmitOrderComment(info);
        }

        /// <summary>
        /// 获取订单列表
        /// </summary>
        /// <param name="info"></param>
        /// <returns></returns>
        [HttpGet]
        public ResponseModel GetOrder([FromQuery] GetOrderInfo info)
        {
            return _homeService.GetOrder(info);
        }
    }
}
